Skip to content

WI01041726 - Legacy Control Migration: Fixes#13

Open
zuizuihao wants to merge 4 commits intomasterfrom
SPG/legacy_patchs
Open

WI01041726 - Legacy Control Migration: Fixes#13
zuizuihao wants to merge 4 commits intomasterfrom
SPG/legacy_patchs

Conversation

@zuizuihao
Copy link
Copy Markdown

@zuizuihao zuizuihao commented Mar 24, 2026

WI01041726 - Legacy Control Migration: Fixes

  • Not Good Fix: avoid type issue when instantiated from ZBindingContext (WI00826420)

    Should not change WinForms source code, will fix ZBindingContext in ZArchitecture.GUI

  • Fixed: comment out Debug.Fail in PaintEventArgs (WI00857973)

    Fixed with another solution, check painteventargs-resetgraphics-failfast.md

  • Fixed In Winforms: keyboard shortcuts associated with menus not being captured (WI00895180)

    Did not reproduce in CargoWise; unsure how it was fixed. Function review required.

  • Fixed: temporarily fixed WebBrowser memory leak (WI00938771)

    Patched back before fixes in commit

  • Fixed: menu popup events not firing (WI00949199)

  • Fixed: menu bar size not taken into account in form sizing (WI00949199)

  • Fixed: menu property change should trigger size update (WI00949199)

    All UTs passed and filenames renamed as below:

    • Tests/System.Windows.Forms.Tests/MenuSizeCalculationTests.cs → MainMenuSizeCalculationTests
    • Tests/System.Windows.Forms.Tests/MainMenuTests.cs → MainMenuPopupTests.cs
    • Tests/System.Windows.Forms.Tests/AdjustWindowRectTests.cs → MainMenuAdjustWindowRectTests.cs
  • Fixed: ToolBar tooltip moving the position of the toolbar (WI00951596)

    All UTs passed

    • Tests/System.Windows.Forms.Tests/ToolBarToolTipTests.cs → ToolBarToolTipTests.cs
  • Fixed: control's anchor info (WI00955507)

    Fixed with new solution in anchor-layout-highDpi-regression.md

  • Fixed: disappearing Owner Draw MenuItem (WI00948012)

    Demo and UTs checked, all passed

    • Tests/System.Windows.Forms.Tests/MenuItemTests.cs → MenuItemTests.cs
  • Fixed In Winforms: IT Customs - NET8 NRE on Customs Declaration MISC Tab (WI01005730)

    .NET 10 includes this change: Fix #12661 Null Reference Exception: System.Windows.Forms.TabControl.<WmSelChange> dotnet/winforms#12683

ZGN-WTG and others added 4 commits March 24, 2026 17:58
Change WebBrowser references in WebBrowserSiteBase and WebBrowserEvent to a WeakReference.
Temporary fix while waiting for dotnet#13769

(cherry picked from commit 1ca4f6d)
…and fix graphics state restoration in PaintEventArgs (WI00857973)
- Added a new button in MainForm to demonstrate the AnchorLayoutHighDpiRegression.
- Refactored Program.cs to set the main method as private and removed unnecessary comments regarding high DPI settings.
- Introduced AnchorLayoutHighDpiRegressionTests to validate the behavior of bottom/right-anchored controls in high DPI scenarios.
- Created a detailed markdown document outlining the high-DPI regression issues and proposed solutions.
- Added compatibility logic in DefaultLayout.AnchorLayoutCompat.cs to handle stale positive anchors and stretch-anchor recovery.
- Updated DefaultLayout.cs to integrate the new compatibility checks for anchor information during layout calculations.
…dotnet#33)

WI00949199 - form size should be recalculated when menu changes (dotnet#36)
@zuizuihao zuizuihao changed the title Patch Fixes from CargoWise.Controls.WinForms.Legacy WI01041726 - Legacy Control Migration: Fixes Apr 2, 2026
if (command == CommandStateChangeConstants.CSC_NAVIGATEBACK)
{
_parent.CanGoBackInternal = enable;
Parent.CanGoBackInternal = enable;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parent could return null.

Suggested change
Parent.CanGoBackInternal = enable;
Parent?.CanGoBackInternal = enable;

else if (command == CommandStateChangeConstants.CSC_NAVIGATEFORWARD)
{
_parent.CanGoForwardInternal = enable;
Parent.CanGoForwardInternal = enable;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

`Parent' could return null

Suggested change
Parent.CanGoForwardInternal = enable;
Parent?.CanGoForwardInternal = enable;

Debug.Assert(urlObject is null or string, "invalid url");
_haveNavigated = true;
if (_parent._documentStreamToSetOnLoad is not null && (string?)urlObject == "about:blank")
if (Parent._documentStreamToSetOnLoad is not null && (string?)urlObject == "about:blank")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

store 'Parent' to a local variable and use it in this method.

{
private readonly WebBrowser _parent;
private readonly WeakReference<WebBrowser> _parent;
private WebBrowser Parent
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As parent could be null now code should be rewritten with this in mind.

/// Retrieves the WebBrowserBase object set in the constructor.
/// </summary>
internal WebBrowserBase Host => _host;
internal WebBrowserBase Host
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check all usages of Host

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants